import axios from 'axios';
import qs from 'qs' // 序列化参数使用的
// import {getH,postH,postJSONH} from "./http"; //引入get和post操作
import { loginreq, req , adminLoginReq , postJSON} from './axiosFun';
import {get} from "../http/http";


//test
export const test = (params) => { return axios.get("get", "/api/order/selectPlOrder", params) };

// 登录接口
// 验证码的请求
export const kaptcha = (params)=>{return axios.get("/api/adminUser/kaptcha")};

// 超级管理员登录
export const adminLogin = (params) => {return req( "post" ,"/api/adminUser/login", params )};
// 角色管理-获取角色列表
export const roleListAdmin = (params) => { return req("post", "/api/adminUser/roleList") };
export const roleListAdminSearch = (params) => { return req("post", "/api/adminUser/roleListSearch", params) };
// 角色管理-所有权限（获取）
export const RoleRightTreeAdminAll = () => { return req("get","/api/adminUser/tree/" ) };
// 角色管理-菜单权限（获取）
export const RoleRightTreeAdmin = (params) => { return req("post","/api/adminUser/ownRole/" , params) };

// 角色管理-删除角色
export const roleDeleteAdmin = (params) => { return req("post","/api/adminUser/deleteRole" ,params)};
//恢复角色
export const roleRobakAdmin = (params) => { return req("post","/api/adminUser/robakRole" ,params)};
//保存角色权限
export const RoleRightSaveAdmin = (params) => { return req("post", "/api/adminUser/saveAdmin", params) };
// 权限管理-获取所有权限
export const ModuleListAll = () => { return req("post", "/api/adminUser/allPermissionList") };
// 菜单管理-获取父级菜单Module/nodes
export const ModuleNodesAdmin = () => { return req("post", "/api/adminUser/nodes") };
// 菜单管理-根据菜单获取数据
export const ModuleGetAdmin = (params) => { return req("post", "/api/adminUser/getOne", params) };
// 菜单管理-修改菜单
export const ModuleSaveAdmin = (params) => { return req("post", "/api/adminUser/savePermission", params) };
// 菜单管理-修改菜单
export const ModuleDeleteAdmin = (params) => { return req("post", "/api/adminUser/deletePermission", params) };
// 用户管理-获取用户列表
export const userListAdmin = (params) => { return req("post", "/api/adminUser/yewuUserList", params) };
// 用户管理-保存（添加编辑）
export const userSaveAdmin = (params) => { return req("post", "/api/adminUser/userSave", params) };
export const userDeleteAdmin = (params) => { return req("post", "/api/adminUser/userDeleteAdmin", params) };
// 用户管理-重置密码
export const userPwdAdmin = (params) => { return req("post", "/api/adminUser/pwd", params) };

// 登录接口
export const login = (params) => { return loginreq("post", "/api/login", params) };
// 获取用户菜单
export const menu = (params) => { return axios.get("/api/menu?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 退出接口
export const loginout = () => { return axios.delete("/api/login?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 停车场用户管理
 **/

// 用户编辑
export const updateUser = (params) => { return req("put", "/api/user/users", params) };
//VIP充值
export const rechargeVip = (params) => { return req("put", "/api/user/vip", params) };
//停车场VIP充值
export const rechargeparkVip = (params) => { return req("put", "/api/user/pVip", params) };
// 获取停车场用户列表
export const userList = (params) => { return req("post", "/api/user/users", params) };
//注销用户
export const deleteUser = (params) => { return req("delete","/api/user/users" ,params ) };

//平台VIP
// 获取平台Vip列表
export const VipUserList = (params) => { return req("post", "/api/user/vipUser", params) };
//获取不是平台vip的用户
export const getNotVipUsers = ()=>{return req("get", "/api/user/vipUser" ) };
export const insertVip = (params) => { return req("post", "/api/user/insertVip", params) };
//删除过期VIP
export const VipDelete = (params) => { return req("delete","/api/user/vipUser" ,params ) };

//停车场
//获取不是停车场VIP 用户
export const getNotParkVipUsers = ()=>{return req("get", "/api/user/parkVip" ) };
// 获取停车场Vip列表
export const parkVipUserList = (params) => { return req("post", "/api/user/parkVip", params) };
//添加停车场VIP
export const insertParkVip = (params) => { return req("post", "/api/user/insertParkVip", params) };
//更新停车场VIP信息
export const updateParkVIP = (params) => { return req("put", "/api/user/parkVip", params) };
//删除过期VIP
export const parkVipDelete = (params) => { return req("delete","/api/user/parkVip" ,params ) };
// export const parkVipUserDelete = (params) => { return req("delete","/api/user/parkVipUser" ,params ) };
//批量清除过期VIP
export const batchDelete = (params) => { return req("delete","/api/user/batchDeleteParkVip" ,params ) };


// 用户管理-保存（添加编辑）
export const userSave = (params) => { return req("post", "/api/User/save", params) };
// 用户管理-删除用户
export const userDelete = (params) => { return axios.delete("/api/User/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 用户管理-重置密码
export const userPwd = (params) => { return req("post", "/api/User/pwd", params) };
// 用户管理-修改状态
export const userLock = (params) => { return axios.get("/api/User/lock?userId=" + params.userId + "&lock=" + params.lock + "&token=" + localStorage.getItem('logintoken')) };
// 用户管理-数据权限
export const UserDeptTree = (params) => { return axios.get("/api/UserDept/tree/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 用户管理-数据权限保存
export const UserDeptSave = (params) => { return req("post", "/api/UserDept/save", params) };
// 用户管理-获取部门设置
export const UserDeptdeptTree = (params) => { return axios.get("/api/UserDept/deptTree/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 用户管理-保存部门设置
export const UserChangeDept = (params) => { return req("post", "/api/User/change/dept", params) };
// 用户管理-用户下线
export const userExpireToken = (params) => { return req("get", "/api/User/expireToken/" + params, {}) };
// 用户管理-刷新缓存
export const userFlashCache = (params) => { return req("get", "/api/User/flashCache/" + params, {}) };

/**
 * 菜单管理
 **/
// 菜单管理-获取菜单Module/list
export const ModuleList = () => { return req("post", "/api/Module/list") };
// 菜单管理-根据菜单获取数据
export const ModuleGet = (params) => { return axios.get("/api/Module/get/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 菜单管理-获取父级菜单Module/nodes
export const ModuleNodes = (params) => { return req("post", "/api/Module/nodes", params) };
// 菜单管理-修改菜单
export const ModuleSave = (params) => { return req("post", "/api/Module/save", params) };
// 菜单管理-删除菜单
export const ModuleDelete = (params) => { return axios.delete("/api/Module/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 角色管理
 **/
// 角色管理-获取角色列表
export const roleList = (params) => { return req("post", "/api/adminUser/roleList", params) };
// 角色管理-保存（添加编辑）
export const roleSave = (params) => { return req("post", "/api/adminUser/save", params) };
// 角色管理-删除角色
export const roleDelete = (params) => { return axios.delete("/api/Role/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 角色管理-菜单权限（获取）
export const RoleRightTree = (params) => { return axios.get("/api/RoleRight/tree/" + params + "?token=" + localStorage.getItem('logintoken')) };
// 角色管理-菜单权限（保存）
export const RoleRightSave = (params) => { return req("post", "/api/RoleRight/save", params) };

/**
 * 公司管理
 **/
// 公司管理-获取公司列表
export const deptList = (params) => { return req("post", "/api/Dept/list", params) };
// 公司管理-保存（添加编辑）
export const deptSave = (params) => { return req("post", "/api/Dept/save", params) };
// 公司管理-删除公司
export const deptDelete = (params) => { return axios.get("/api/Dept/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 系统环境变量
 **/
// 系统环境变量-获取系统环境变量列表
export const variableList = (params) => { return req("post", "/api/Variable/list", params) };
// 系统环境变量-保存（添加编辑）
export const variableSave = (params) => { return req("post", "/api/Variable/save", params) };
// 系统环境变量-删除系统环境变量
export const variableDelete = (params) => { return axios.delete("/api/Variable/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };

/**
 * 权限管理
 **/
// 权限管理-获取权限列表
export const permissionList = (params) => { return req("post", "/api/Permission/list", params) };
// 权限管理-保存权限
export const ermissionSave = (params) => { return req("post", "/api/Permission/save", params) };
// 权限管理-删除权限
export const ermissionDelete = (params) => { return axios.delete("/api/Permission/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 权限管理-获取权限
export const roleDropDown = () => { return axios.get("/api/Role/dropDown/all?&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
// 权限管理-配置权限
export const RolePermission = (params) => { return req("post", "/api/RolePermission/save", params) };




//////////////////////////////////////////////////////////////////////////////////

//获取所有vip类型
export const getVipTypes = () => { return req("get", "/api/vip/all") };
//更新vip类型
export const editVipType = (vipType) => { return req("post", "/api/vip/update",vipType) };
//删除vip类型
export const deleteVipType = (vipType) => { return req("post", "/api/vip/delete",vipType) };
//添加vip类型
export const addVipType = (vipType) => { return req("post", "/api/vip/add",vipType) };
//获取所有的Vip用户
export const getVipUsers = (vipType) => { return req("post", "/api/vip/vipUsers",vipType) };
//  更新用户的Vip到期时间等信息
export const submitEditUserVip = (vipType) => { return req("post", "/api/vip/vipUser",vipType) };
// 修改用户的vip状态
export const updateUserVipState = (vipType) => { return req("post", "/api/vip/vipUserState",vipType) };

////////////////////////////////////
//获取停车场Vip的类型信息
export const getPKVipTypes = () => { return req("get", "/api/pkvip/viptypes") };
// 添加停车场vip类型
export const addPKVipType = (vipType) => { return req("post", "/api/pkvip/add",vipType) };
//更新停车场vip类型
export const updatePKVipType = (vipType) => { return req("post", "/api/vip/update",vipType) };
//删除停车场vip类型
export const deletePKVipType = (vipType) => { return req("post", "/api/vip/delete",vipType) };

//////////////////////
//获取当前停车场的所有的Vip用户的订单情况  getVipUsers
export const getPKVipUserOrders = (parkingOrder) => { return req("post", "/api/pkvip/userOrder",parkingOrder) };
//获取当前停车场的所有的Vip用户的订单情况  getVipUsers
export const getPKVipUserOrder = (parkingOrder) => { return req("post", "/api/pkvip/userOrders",parkingOrder) };
/////////////////////////////////////////
//获取停车场优惠券
export const getPKCoupons = (coupon) => { return req("post", "/api/coupon/all",coupon) };
//添加停车场优惠券
export const addPKCoupon = (coupon) => { return req("post", "/api/coupon/add",coupon) };
// 更新停车场优惠券的相关信息
export const submitEditPKCoupon = (coupon) => { return req("post", "/api/coupon/update",coupon) };
